import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Layouts

Rectangle {
    Layout.fillWidth: true
    Layout.fillHeight: true

    // 使用 Flickable 包装 TextArea
    Flickable {
        id: flickable
        anchors.centerIn: parent
        width: parent.width * 0.8
        height: parent.height * 0.8
        contentWidth: textArea.width
        contentHeight: textArea.height
        clip: true

        TextArea {
            id: textArea
            width: flickable.width
            height: Math.max(flickable.height, implicitHeight)
            placeholderText: "自定义样式的文本区域"
            wrapMode: TextArea.Wrap
            text: "这是一个测试文本，用于演示滚动功能。\n".repeat(30)
            selectByMouse: true
            mouseSelectionMode: TextEdit.SelectCharacters

            background: Rectangle {
                implicitWidth: flickable.width
                implicitHeight: flickable.height
                color: textArea.enabled ? "white" : "#f5f5f5"
                border.color: textArea.activeFocus ? "#1296FF" : "#c0c0c0"
                border.width: textArea.activeFocus ? 2 : 1
                radius: 4
            }
        }
    }
}
